﻿using System.Collections.Generic;
using System.Text;
using System.Web.UI.WebControls;
using Hidistro.SaleSystem.Catalog;
using System.Web;
using System.Web.UI;
using Hidistro.Entities.Commodities;
using Hidistro.Core;

namespace Hidistro.UI.SaleSystem.Tags
{
    public class wnxd_SubPageURL : WebControl
    {
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write(this.RendHtml());
        }

        public string RendHtml()
        {
            StringBuilder builder = new StringBuilder();
            if (this.type == 1)
            {
                int categoryId = int.Parse((HttpContext.Current.Handler as System.Web.UI.Page).Request.QueryString["CategoryId"]);
                builder.AppendFormat("<h4>");

                CategoryInfo category = CategoryBrowser.GetCategory(categoryId);
                builder.AppendFormat("" + category.Name);
                builder.AppendFormat("</h4><div class=\"content1-left-box\">");

                List<CategoryInfo> list = CategoryBrowser.GetMaxSubCategories(category.CategoryId, 0x3e8) as List<CategoryInfo>;
                foreach (CategoryInfo ca in list)
                {
                    builder.AppendFormat("<a href=\"{0}\" >", Globals.GetSiteUrls().SubCategory(ca.CategoryId, ca.RewriteName, ca.ParentRewriteName));
                    builder.AppendFormat("" + ca.Name);
                    builder.AppendFormat("</a>");
                }

                builder.AppendFormat("</div>");
            }
            else if (this.type == 2)
            {
            }
            else if (this.type == 3)
            {
            }
            return builder.ToString();
        }
        public int type { get; set; }
    }
}
